<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<title>登录页面 - Thor后台管理系统</title>
<link rel="icon" href="/static/favicon.ico" type="image/ico">
<link href="/static/css/bootstrap.min.css" rel="stylesheet">
<link href="/static/css/materialdesignicons.min.css" rel="stylesheet">
<link href="/static/css/animate.css" rel="stylesheet">
<link href="/static/css/style.min.css" rel="stylesheet">
<style>
.lyear-wrapper {
    position: relative;
}
.lyear-login {
    display: flex !important;
    min-height: 100vh;
    align-items: center !important;
    justify-content: center !important;
}
.login-center {
    background: #fff;
    min-width: 38.25rem;
    padding: 2.14286em 3.57143em;
    border-radius: 5px;
    margin: 2.85714em 0;
}
.login-header {
    margin-bottom: 1.5rem !important;
}
.login-center .has-feedback.feedback-left .form-control {
    padding-left: 38px;
    padding-right: 12px;
}
.login-center .has-feedback.feedback-left .form-control-feedback {
    left: 0;
    right: auto;
    width: 38px;
    height: 38px;
    line-height: 38px;
    z-index: 4;
    color: #dcdcdc;
}
.login-center .has-feedback.feedback-left.row .form-control-feedback {
    left: 15px;
}
</style>
</head>
  
<body>
<div class="row lyear-wrapper">
  <div class="lyear-login">
    <div class="login-center">
      <div class="login-header text-center">
        <a href="javascript:;"> <img alt="light year admin" src="/static/images/logo-sidebar.png"> </a>
      </div>
      <form method="post" id="login_form">
        <div class="form-group has-feedback feedback-left">
          <input type="text" placeholder="请输入您的用户名" class="form-control" name="userName" id="userName" value="admin" />
          <span class="mdi mdi-account form-control-feedback" aria-hidden="true"></span>
        </div>
        <div class="form-group has-feedback feedback-left">
          <input type="password" placeholder="请输入密码" class="form-control" id="userPassword" name="userPassword" value="123456" />
          <span class="mdi mdi-lock form-control-feedback" aria-hidden="true"></span>
        </div>
        <div class="form-group has-feedback feedback-left row">
          <div class="col-xs-7">
            <input type="text" name="captcha" class="form-control" placeholder="验证码">
            <span class="mdi mdi-check-all form-control-feedback" aria-hidden="true"></span>
          </div>
          <div class="col-xs-5">
            <div id="v_container" style="width: 120px;height: 38px;"></div>
          </div>
        </div>
        <div class="form-group has-feedback feedback-left">
            <label class="lyear-checkbox checkbox-primary m-t-10">
                <input type="checkbox" name="rememberMe" id="rememberMe">
                <span>记住我</span>
            </label>
        </div>
        <div class="form-group">
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          <button id="log_btn" class="btn btn-label btn-primary" type="button" onclick="login();"><label><i class="mdi mdi-checkbox-marked-circle-outline"></i></label>立即登录</button>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          <button class="btn btn-label btn-cyan" type="button" onclick="reg();"><label><i class="mdi mdi-account-plus"></i></label>立即注册</button>
        </div>
      </form>
      <hr>
      <footer class="col-sm-12 text-center">
        <p class="m-b-0" style="font-size: 12px;color: #a5b3c7">Copyright © 2019 LiJunYi<a href="http://www.beian.miit.gov.cn/">&nbsp;&nbsp;浙ICP备19020174号</a></p>
      </footer>
    </div>
  </div>
</div>
<script type="text/javascript" src="/static/js/jquery.min.js"></script>
<script type="text/javascript" src="/static/js/bootstrap.min.js"></script>
<!--消息提示-->
<script src="/static/js/bootstrap-notify.min.js"></script>
<script type="text/javascript" src="/static/js/lightyear.js"></script>
<script type="text/javascript" src="/static/js/main.min.js"></script>
<!--验证码-->
<script type="text/javascript" src="/static/js/gVerify.js"></script>
<script type="text/javascript" src="/static/js/background.js"></script>
<script type="text/javascript">
  /*初始化验证码*/
  var verifyCode = new GVerify("v_container");
  /*登录方法*/
  function login(){
    lightyear.loading('show');  // 显示
    var res = verifyCode.validate($("input[name$='captcha']").val());
    var formData = $("#login_form").serialize();
    if(res){
      $("#log_btn").attr("disabled","disabled");
      $.ajax({
        url:"/sys/login",
        type:"post",
        data:formData,
        success:function (obj) {
          if("登录成功" == obj){
              window.location.href="/page/index";
              lightyear.loading('hide');  // 隐藏
          }else{
              $("#log_btn").removeAttr("disabled");
              lightyear.notify(obj, 'danger', 1000, 'mdi mdi-close-circle-outline', 'top', 'center');
            lightyear.loading('hide');  // 隐藏
          }
        }
      });
    }else{
      lightyear.notify('验证码错误!', 'danger', 1000, 'mdi mdi-close-circle-outline', 'top', 'center');
      lightyear.loading('hide');  // 隐藏
    }
  }
  // 注册页面
  function reg() {
      window.location.href="/page/registered";
  }

  window.onload = function () {
    var href = location.href;
    console.log(href.indexOf("kickout") > 0);
    if (href.indexOf("kickout") > 0){
      lightyear.notify('您的账号在另一台设备上登录，您被挤下线，若不是您本人操作，请立即修改密码！', 'danger', 3000, 'mdi mdi-close-circle-outline', 'top', 'center');
    }
  }
</script>
</body>
</html>